home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / dsp / dr.bub / 96000.lha / 96000 / appb / b137.asm < prev    next >
Assembly Source File  |  1992-04-28  |  4KB  |  69 lines

  1. ; This program was originally published in the Motorola DSP96002 Users Manual
  2. ; and is provided under a DISCLAIMER OF WARRANTY available from Motorola DSP
  3. ; Operation, 6501 William Cannon Drive West, Austin, Texas 78735-8598.  For
  4. ; more information, refer to the DSP96002 Users Manual, Appendix B, DSP
  5. ; Benchmarks.
  6. ;
  7. ; B.1.37    Bezier Cubic Polynomial Evaluation  
  8. ;Bezier polynomials are used to represent curves and surfaces in  graphics.  The Bezier form requires 
  9. ;four points: two endpoints and  two points other points.  The four points define (in two dimen-
  10. ;sions)  a convex polygon.  The curve is bounded by the edges of the polygon.  
  11. ;A typical application of the Bezier cubic is generating character  fonts for laser printers using the 
  12. ;postscript notation.  
  13. ;Given the four sets of points, the cubic equation for the X  coordinate is:  
  14. ;x(t)=(P1x)*(1-t)**3 + (P2x)*3*t*(t-1)**2 + (P3x)*3*t*t*(1-t) + (P4x)t**3 
  15. ;where: 
  16. ;    P1x = x coordinate of an endpoint 
  17. ;    P2x = a point used for defining the convex polygon 
  18. ;    P3x = a point used for defining the convex polygon 
  19. ;    P4x = x coordinate of an endpoint 
  20. ;    0.0 <= t <= 1.0 
  21.  
  22. ;As t varies from zero to one, the x coordinate moves along the cubic  from one endpoint to the oth-
  23. ;er.  
  24. ;With a little inspiration, the equation can be factored as:  
  25. ;x(t)=-(t-1)**3*(P1X) + 3t(t-1)**2*(P2x) - 3t*t(1-t)*(P3x) + t**3*(P4x) 
  26. ;x(t)=(t-1)(-(t-1)**2*(P1x)+3t{(t-1)*(P2x)-t*(P3x)}) + t**3*(P4x) 
  27. ;
  28. ;Memory Map:               X    Y 
  29. ;             r4 ?  t                   1.0 
  30. ;                                       3.0 
  31. ;                   P1x 
  32. ;                   P2x 
  33. ;             r0 ? P3x 
  34. ;                   P4x 
  35. ;The P coefficients are accessed in the order: P3x,P2x,P1x,P4x. 
  36. ;              Bezier Cubic Evaluation                       Program    ICycles 
  37. ;                                                            Words 
  38.   move   #Ptable+2,r0 
  39.   move   #2,n0 
  40.   move   #TK,r4 
  41.  
  42.   move                          x:(r0)-,d4.s             ; 1        1 
  43.   move                          x:(r4)+,d0.s y:,d5.s     ; 1        1 
  44.   fmpy   d4,d0,d1 fsub.s d5,d0  x:(r0)-,d4.s d0.s,d5.s   ; 1        1 
  45.   fmpy.s d4,d0,d2                            y:(r4)-,d4.s; 1        1 
  46.   fmpy   d4,d5,d1 fsub.s d1,d2                           ; 1        1 
  47.   fmpy.s d1,d2,d2                                        ; 1        1 
  48.   fmpy.s d0,d0,d1               x:(r0)+n0,d4.s           ; 1        1 
  49.   fmpy.s d1,d4,d1               d5.s,d4.s                ; 1        1 
  50.   fmpy   d4,d4,d1 fsub.s d1,d2                           ; 1        1 
  51.   fmpy.s d0,d2,d2                                        ; 1        1 
  52.   fmpy.s d1,d4,d1               x:(r0)+n0,d5.s           ; 1        1 
  53.   fmpy.s d1,d5,d1                                        ; 1        1 
  54.   fadd.s d1,d2                                           ; 1        1 
  55.                                                          ;---      --- 
  56.                                                 ; Totals:  13       13 
  57.  
  58. ;The result x(t) is in d2.  The setup of the pointers is not included  because this is application depen-
  59. ;dent and does not have to be performed  for each evaluation of x(t).  The first two moves may also 
  60. ;be  application dependent and be merged with other data ALU operations  for a savings of two more 
  61. ;cycles and program steps.  
  62. ;Reference: "Fundamentals of Interactive Computer Graphics", 
  63. ;                  James D. Foley Andries Van Dam 
  64. ;                  Addison-Wesley 1982 
  65.